<template>
  <div class="goods">
    <pageSearch
      :searchFormConfig="searchFormConfig"
      @queryBtnClick="handleSearch"
      @resetBtnClick="handleReset"
    />
    <pageContent ref="pageContentRef" :contentTableConfig="contentTableConfig" pageName="goods">
      <template #image="scope">
        <el-image
          style="width: 60px; height: 60px"
          :src="scope.row.imgUrl"
          :preview-src-list="[scope.row.imgUrl]"
        >
        </el-image>
      </template>
      <template #status="scope">
        <el-tag :type="scope.row.status ? 'success' : 'danger'">
          {{ scope.row.status ? '启用' : '禁用' }}
        </el-tag>
      </template>
      <template #oldPrice="scope">
        <span>￥{{ scope.row.oldPrice }}</span>
      </template>
    </pageContent>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'

import { searchFormConfig } from './config/search.config'
import { contentTableConfig } from './config/content.config'

import pageSearch from '@/components/page-search'
import pageContent from '@/components/page-content'

import { usePageSearch } from '@/hooks/usePageSearch'

export default defineComponent({
  name: 'goods',
  components: { pageSearch, pageContent },
  setup() {
    const [pageContentRef, handleSearch, handleReset] = usePageSearch()
    return {
      searchFormConfig,
      contentTableConfig,
      pageContentRef,
      handleSearch,
      handleReset
    }
  }
})
</script>

<style scoped></style>
